/*
 * 程序入口
 */
import Taro from "@tarojs/taro";
import {Provider} from "@tarojs/redux";
import Index from "./pages/index/index";
import {store} from "./store/store";
import "./app.scss";

/*if (process.env.NODE_ENV === 'development') {

} else {
    // require('path/to/h5/name')
    console.log('production');
}*/

// const ENV_TYPE = Taro.getEnv();

class App extends Taro.Component {
    config = {
        pages: [
            'pages/home/home', //首页
            'pages/home/detail/detail', //详情页

            'pages/index/index', //课程
            'pages/index/map/map', //地图页面
            'pages/index/search/search', //搜索页面
            'pages/index/select-area/selectArea', //选择区域
            'pages/index/course-list/courseList', //课程列表
            'pages/index/course-detail/courseDetail', //课程详情
            'pages/index/classroom-list/classroomList', //教室列表
            'pages/index/classroom-detail/classroomDetail', //教室详情
            'pages/index/classroom-detail-next/classroomDetailNext', //教室详情
            'pages/index/train-list/trainList', //教练列表
            'pages/index/affirm-success/affirmSuccess', //支付成功
            'pages/index/affirm-detail/affirmDetail', //确认订单
            'pages/index/train-detail/trainDetail', //教练详情

            //发布
            'pages/issue/issue', //发布
            'pages/issue/issuePage/issuePage', //发布页面
            'pages/issue/addCourse/addCourse', //添加课程

            //教室
            'pages/classroom/classroom', //教室

            //学习
            'pages/order/order', //我的
            'pages/order/order-detail/orderDetail', //订单详情页
            'pages/order/order-detail-next/orderDetailNext', //订单详情页1

            //设置
            'pages/my/my', //
            'pages/my/my-take/myTake', //我的收藏
            'pages/my/my-balance/myBalance', //我的余额
            'pages/my/meal-list/mealList', //套餐列表
            'pages/my/my-coupon/myCoupon', //我的优惠卷
            'pages/my/my-dynamic/myDynamic', //我的动静

            'pages/my/my-train/myTrain', //教练页面
            'pages/my/my-train-none/myTrainNone',
            'pages/my/train-apply/trainApply', //教练申请
            'pages/my/train-coursey/trainCourse', //教练课程  (我的课程)
            'pages/my/select-coursey/selectCourse', //教练课程  (选择课程)
            'pages/my/add-coursey/addCourse', //添加教练课程  (添加课程)
            'pages/my/coursey-detail/courseDetail', //教练课程详情  (教练课程详情)
            'pages/my/my-arranging/myArranging', //教练安排课程  (我的排课)
            'pages/my/arranging-coursey/arrangingCoursey', //教练安排课程  (正在排课)
            'pages/my/arranging-coursey-next/arrangingCourseyNext', //教练安排课程  (正在排课)
            'pages/my/train-order/trainOrder', //教练订单页  (订单页)
            'pages/my/order-detail-next/orderDetailNext', //订单详情页1
            'pages/my/select-map/selectMap', //教室选择  地图

            'pages/my/my-classroom/myClassroom', //教室页面
            'pages/my/classroom-apply/classroomApply', //教室申请
            'pages/my/classroom-detail/classroomDetail', //教室详情页
            'pages/my/add-classroom-time/addClassroomTime', //教室添加时间（教室上传安排时间）
            ],
        window: {
            backgroundTextStyle: 'light',
            navigationBarBackgroundColor: '#ffffff',
            navigationBarTitleText: '动态镜子',
            navigationBarTextStyle: 'black',
            backgroundColor: '#F9F9F9',
            enablePullDownRefresh: false
        },
        requiredBackgroundModes: ["audio", "backgroundAudioManager"], //微信客户端 6.7.2 及以上版本支持
        networkTimeout: {
            request: 30000,
            downloadFile: 60000
        },
        permission: {
            "scope.userLocation": {
                "desc": "实体商家导航"
            }
        },
        navigateToMiniProgramAppIdList:[],
        tabBar: {
            color: '#393A3B',
            selectedColor: '#008589',
            borderStyle: 'black',
            list: [
                {
                    selectedIconPath: './asset/images/home_in.png',
                    iconPath: './asset/images/home.png',
                    pagePath: 'pages/home/home',
                    text: '首页'
                },
                {
                    selectedIconPath: './asset/images/shop_in.png',
                    iconPath: './asset/images/shop.png',
                    pagePath: 'pages/index/index',
                    text: '课程'
                },
                {
                    selectedIconPath: './asset/images/plus.png',
                    iconPath: './asset/images/plus.png',
                    pagePath: 'pages/issue/issue',
                    text: ''
                },
                {
                    selectedIconPath: './asset/images/order_in.png',
                    iconPath: './asset/images/order.png',
                    pagePath: 'pages/order/order',
                    text: '我的预约'
                },
                {
                    selectedIconPath: './asset/images/mine_in.png',
                    iconPath: './asset/images/mine.png',
                    pagePath: 'pages/my/my',
                    text: '我的'
                }
                ]
        }
    }
    // componentWillMount() {
    //     console.log('app componentWillMount');
    //     console.log('app componentWillMount $router.params', this.$router.params);
    //     // 微信小程序版本升级
    //     if(process.env.TARO_ENV === 'weapp') {
    //         const updateManager = Taro.getUpdateManager();
    //         updateManager.onCheckForUpdate((res) => {
    //             // 请求完新版本信息的回调
    //             console.log('版本更新',res.hasUpdate)
    //         })
    //
    //         updateManager.onUpdateReady(() => {
    //             Taro.showModal({
    //                 title: '更新提示',
    //                 content: '新版本已经准备好，是否重启应用？',
    //                 success: (confirm, cancel) => {
    //                     console.log(confirm, cancel);
    //                     if (confirm) {
    //                         // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
    //                         updateManager.applyUpdate();
    //                     }
    //                 }
    //             })
    //         })
    //
    //         // 新的版本下载失败
    //         updateManager.onUpdateFailed(() => {
    //             Taro.showModal({
    //                 title: '更新提示',
    //                 content: '新版本下载失败',
    //                 showCancel: false
    //             })
    //         })
    //     }
    // }

    render () {
        return (
            <Provider store={store}>
                <Index />
            </Provider>
        )
    }
}

export default App;

Taro.render(<App />, document.getElementById('app'));
